//
//  ManageFriendsViewController.m
//  CandyCrushClone
//
//  Created by Petar on 2/22/15.
//  Copyright (c) 2015 Nestorov Engineering. All rights reserved.
//

#import "ManageFriendsViewController.h"
#import "CommunicationManager.h"
#import "Globals.h"

@interface ManageFriendsViewController ()

@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation ManageFriendsViewController
{
    
    NSArray *_buddyList;
    CommunicationManager *_communicationManager;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _communicationManager = [CommunicationManager sharedManager];
    _buddyList = [_communicationManager getBuddyList];
    
}


#pragma mark - Table view data source / delegate methods
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_buddyList count];
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    static NSString *CellIdentifier = @"FriendCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    
    SFSBuddy *buddy = _buddyList[indexPath.row];
    
    // Set Buddy name as text in the label
    ((UILabel *)[_tableView viewWithTag:1]).text = buddy.name;
    
    return cell;
    
}


- (IBAction)didPressBackButton:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (BOOL)prefersStatusBarHidden
{
    return YES;
}

@end
